<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <title>admin</title>

    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="shortcut icon" href="/favicon.ico"/>
    <link rel="stylesheet" type="text/css" href="/static/css/admin/bootstrap.min14ed.css"/>
    <link rel="stylesheet" type="text/css" href="/static/css/admin/font-awesome.min93e3.css"/>
    <link rel="stylesheet" type="text/css" href="/static/css/admin/animate.min.css"/>
    <link rel="stylesheet" type="text/css" href="/static/css/admin/plugins/chosen/chosen.css"/>
    <link rel="stylesheet" type="text/css" href="/static/css/admin/plugins/datapicker/datepicker3.css"/>
    <link rel="stylesheet" type="text/css" href="/static/css/admin/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css"/>
    <link rel="stylesheet" type="text/css" href="/static/css/admin/style.min862f.css"/>
    <link href="/static/css/admin/laydate.css" rel='stylesheet' type='text/css'/>
    <link href="/static/css/admin/admincommon.css?v=20181116" rel='stylesheet' type='text/css'/>
    <link href="/static/css/layui/css/layui.css" rel='stylesheet' type='text/css'/>
</head>
<style type="text/css">
    .chosen-container-multi {
        margin-left: 16px;
    }
</style>
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <form id="about_form" method="post" class="form-horizontal">
        <div class="row">
            <div class="form-group">
                <label class="col-sm-1 control-label">启动页图片</label>
                <div class="col-sm-2">
                    <input type="file" id="article_poster" name="file" value="" class="form-control input-file"
                           onchange="getImgData(this);" style="height:40px;">
                    <input type="hidden" id="img_url" name="img_url" value="{$data['img_url']}" class="form-control input-file">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-1 control-label">外链地址</label>
                <div class="col-sm-6">
                    <input type="text" name="outer_url" value="{$data['outer_url']}" class="form-control">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-1 control-label">状态</label>
                <div class="col-sm-6">
                    <select class="form-control m-b chosen-select" name="status" id="status">
                        <option value="1" <if condition="$data['status'] eq 1">selected</if>>启用</option>
                        <option value="0" <if condition="$data['status'] eq 0">selected</if>>关闭</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-1 control-label">排序</label>
                <div class="col-sm-6">
                    <input type="text" name="sort" value="{$data['sort']}" class="form-control">
                </div>
            </div>
            <div style="margin-left: 140px" class="row">
                <button class="btn btn-primary" type="submit">保存内容</button>
            </div>
        </div>
    </form>
</div>
<script src="/static/js/admin/laydate.js" type="text/javascript"></script>
<js href="/static/js/admin/jquery.min.js"/>
<js href="/static/js/admin/bootstrap.min.js"/>
<js href="/static/js/admin/content.min.js"/>
<js href="/static/js/admin/plugins/chosen/chosen.jquery.js"/>
<js href="/static/js/admin/plugins/layui/layer/layer.js"/>
<js href="/static/js/admin/plugins/datapicker/bootstrap-datepicker.js"/>
<js href="/static/css/layui/layui.js"/>
<script>
    laydate.render({
        elem: '#test1', //指定元素
        type: 'datetime',
        format: 'yyyy-MM-dd HH:mm:ss', //指定时间格式
    });

    function getImgData(obj) {
        var file = obj.files[0];
        var formData = new FormData();
        formData.append('file', file);

        $.ajax({
            url: "{:url('admin/Upload/uploadToQiNiu')}?isupload=2&folder=hpage",
            type: 'post',
            processData: false,  // 异步传输 formData 时要加上  processData: false  contentType: false
            contentType: false,  // 否则会报 Illegal invocation 非法调用错误
            data: formData,
            success: function (data) {
                if (data.code == 1) {
                    console.log(data.data);
                    $('#img_url').val(data.data);
                } else {
                    layer.msg(data.msg, {time: 800, icon: 2});
                }
            },
            dataType: 'json'
        });

    }

</script>
</body>
</html>
